package com.yc.yuehui.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yc.yuehui.entity.YhPhotoRace;
import com.yc.yuehui.mapper.YhPhotoRaceMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyl
 * @since 2023-03-07
 */
@Controller
@RequestMapping("/yuehui/yhPhotoRace")
public class YhPhotoRaceController {

    @Resource
    private YhPhotoRaceMapper mapper;

    @GetMapping("queryPage")
    @ResponseBody
    public Page<YhPhotoRace> queryPage(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "5") int size){
        List<YhPhotoRace> list = mapper.selectPage((pageNum - 1) * size, size);
        long count = mapper.countPage();
        Page<YhPhotoRace> p = new Page<>(pageNum, size);
        p.setTotal(count);
        p.setRecords(list);
        return p;
    }
}

